package cn.exrick.xboot.modules.content.entity;

import cn.exrick.xboot.common.utils.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
import java.util.Map;

@Entity
@Table(name = "hont_log")
@Data

public class HontLog {
    @Id
    @Column(name = "id")
    private String id;
    private static final long serialVersionUID = 1L;

    private String name;

    private Integer logType;

    private String requestUrl;

    private String requestType;

    private String requestParam;

    private String username;

    private String nickName;

    private String ip;

    private String ipInfo;

    private Integer costTime;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 转换请求参数为Json
     * @param paramMap
     */
    public void setMapToParams(Map<String, String[]> paramMap) {

        this.requestParam = ObjectUtil.mapToString(paramMap);
    }
}
